#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=5e3+100;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL a[maxn],b[maxn];
LL dp[maxn][maxn];
LL n;
LL dfs(LL l,LL r){
   if(l>=r) return 0;
   if(dp[l][r]!=-1) return dp[l][r];
   dp[l][r]=dfs(l+1,r-1)+a[l]*b[r]+a[r]*b[l]-a[l]*b[l]-a[r]*b[r];
   return dp[l][r];
}
int main(void){
   cin.tie(0);std::ios::sync_with_stdio(false);
   cin>>n;
   for(int i=1;i<=n;i++) cin>>a[i];
   for(int i=1;i<=n;i++) cin>>b[i];
   LL sum=0;
   for(int i=1;i<=n;i++) sum+=a[i]*b[i];
   memset(dp,-1,sizeof(dp));
   LL res=0;
   for(int i=1;i<=n;i++){
       for(int j=1;j<=n;j++){
          res=max(res,dfs(i,j));
       }
   }
   cout<<sum+res<<"\n";
   return 0;
}
